package com.Object01.homework.homework05;

public class Homework05 {
    public static void main(String[] args) {
        Person temp = null;
        Person[] people = new Person[4];
        people[0] = new Student("jack", "男", 18, "220");
        people[1] = new Student("mary", "女", 20, "221");
        people[2] = new Teacher("smith", "女", 50, "10");
        people[3] = new Teacher("bob", "男", 35, "5");
        for (int i = 0 ; i < people.length - 1 ; i++) {
            for (int j = 0 ; j < people.length - 1 - i ; j++){
                if (people[j].getAge() < people[j+1].getAge()){
                    temp = people[j];
                    people[j] = people[j+1];
                    people[j+1] = temp;
                }
            }
        }
        for (int i = 0 ; i < people.length ; i++) {
            if (people[i] instanceof Student) {
                ((Student) people[i]).aVoid();
            }
            if (people[i] instanceof Teacher) {
                ((Teacher) people[i]).aVoid();
            }
        }
        for (int i = 0 ; i < people.length ; i++) {
            people[i].test(people[i]);
        }
    }
}
